package IViews;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

public class ICheckbox extends JLabel{

	final static int FINALWIDTH = 94;
	final static int FINALHEIGHT = 27;
	
	private boolean value = false;
	
	public ICheckbox(int x, int y, boolean pValue){
		this.setBounds(x, y, 94, 27);
		this.value = pValue;
		this.redrawImage();
		this.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				changeValue();
			}
		});
	}

	private void redrawImage(){
		if(value){
			this.setIcon(new ImageIcon("res/checkboxON.jpg"));
		}else{
			this.setIcon(new ImageIcon("res/checkboxOFF.jpg"));
		}
	}
	
	private void changeValue(){
		value = !value;
		redrawImage();
	}
	
	public boolean getValue(){
		return value;
	}
	
}
